# send_packet.py
from scapy.all import *
import sys

from scapy.layers.inet import UDP, IP

# 从命令行参数获取数据
src_ip = sys.argv[1]
dst_ip = sys.argv[2]
dst_port = int(sys.argv[3])
data = sys.argv[4]

# 构造IP层和UDP层
ip = IP(src=src_ip, dst=dst_ip)
udp = UDP(sport=12345, dport=dst_port)  # 源端口可以是任意的

# 发送数据包
send(ip/udp/data)
